@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="row">
                <div class="col-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">请修改黑名单信息</h4>
                            {{--<p class="card-description">--}}
                            {{--Basic form elements--}}
                            {{--</p>--}}
                            <form class="forms-sample" id="form">
                                <div class="form-group">
                                    <label >* 黑名单名称</label>
                                    <input type="text"  class="form-control required" name="name" placeholder="Refer名称" value="{{ $config->name }}">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword4">* 选择配置类型</label>
                                    <select class="form-control required" id="type" name="type">
                                        <option value="1" @if($config->type == 1) selected @endif>域名(Domain)</option>
                                        <option value="2" @if($config->type == 2) selected @endif>App(X-Requested-With)</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label >* 配置值(域名/X-Requested-With)</label>
                                    <input type="text"  class="form-control required" name="url" placeholder="Domain or UserAgent" value="{{ $config->url }}">
                                </div>
                                <div class="form-group">
                                    <div class="row" style="margin-left: 10px;">
                                        <div class="form-check col-2" >
                                            <label class="form-check-label">
                                                <input type="radio" name="status" class="form-radio-input td-radio" value="1" @if($config->status == 1) checked @endif>启用
                                            </label>
                                        </div>
                                        <div class="form-check col-2">
                                            <label class="form-check-label">
                                                <input type="radio" name="status" class="form-radio-input td-radio" value="0" @if($config->status == 0) checked @endif>禁用
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <button type="button" onclick="commit({{ $config->id }})" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                    提交
                                </button>
                                <button type="button" onclick="cancel()" class="btn btn-sm btn-gradient-warning btn-icon-text">
                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
                                    取消
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function commit(id){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/admin/refer/update/"+id,"post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
